from network.network import ServerSocket
import sys
import logging
from exception import DisconnectedError

def controller(pack, user):
    print("\n", pack)
    return (pack, user)

# logging.basicConfig(filename='example-server.log', level=logging.INFO)
logging.basicConfig(level=logging.INFO)
server = ServerSocket("localhost", int(sys.argv[1]))
print("Server is running at {}:{}".format(*server.host))
try:
    server.run(controller)
except KeyboardInterrupt:
    print("\nStopping server")
except Exception as e:
    print(e)
finally:
    server.close()

